#include"Structt.h"
#include"Menu.h"
#include"function.h"

void menu(Student* s,int n)
{
	while(1){
		system("CLS");
		printf("\n\t学生健康档案管理系统\n");
		printf("\t1.登记\n");
		printf("\t2.修改\n");
		printf("\t3.删除\n");
		printf("\t4.查询\n");
		printf("\t5.统计\n");
		printf("\t6.显示所有学生信息及病例\n");
		printf("\t0.退出\n");
		printf("\t（0-5）\n");
		int option ;
		scanf("%d",&option);
		switch(option){
			case 0:
				return ;
				break;
				
			case 1 :
				menu1( s,n );
				break;
			
			case 2 :
				menu2( s,n );
				break;
			
			case 3 :
				menu3( s,n );
				break;
			
			case 4 :
				menu4( s,n );
				break;
			
			case 5 :
				menu5( s,n );
				break;
			
		    case 6:
		    	traversal( s,n );
		    	break;
		    
			default :
				continue;
		}
	
	system("pause");
	
	}
}
void menu1(Student* s,int n)
{	
	while(1){
		system("cls");
		printf("\t1.登记\n");
		printf("\t2.添加\n");
		printf("\t0.退出\n");
		printf("\t（0-1）\n");
		int option ;
		
		scanf("%d",&option);
		switch(option){
			case 0:
				return ;
				break;
				
		    case 1:
			    input1( s,n );
				break;	
			
			case 2:
			    add( s,n );
			    break;
				
			default :
			    continue;	
		}
	
	system("pause");
	
	}
}
void menu2(Student* s,int n)
{
	while(1){
		system("cls");
		printf("\t1.修改\n");
		printf("\t0.退出\n");
		printf("\t（0-1）\n");
		int option ;
		scanf("%d",&option);
		switch(option){
			case 0:
				return ; 
				break;
				
		    case 1:
			    change( s,n );
				break;	
			
			default :
			    continue;	
		}
	
	system("pause");
	
	}
}
void menu3(Student* s,int n)
{
	while(1){
		system("cls");
		printf("\t1.删除\n");
		printf("\t0.退出\n");
		printf("\t（0-1）\n");
		int option ;
		scanf("%d",&option);
		switch(option){
			case 0:
				return ;
				break;
				
		    case 1:
			    deletE( s,n );
				break;
			
			default :
			    continue;		
		}
	
	system("pause");
	
	}
}
void menu4(Student* s,int n)
{
	while(1){
		system("cls");
		printf("\t1.依据学号\n");
		printf("\t2.依据性别\n");
		printf("\t3.依据姓名\n");
		printf("\t0.退出\n");
		printf("\t（0-3）\n");
		int sno;
		char name[30];
		char gender[3];
		
		int option ;
		scanf("%d",&option);
		switch(option){
			case 0:
				return ;
				break;

		    case 1:
		    	printf("\n\tsno:");
		    	scanf("%d",&sno);
			    find_by_sno( s,n,sno );
				break;	
			
			case 2:
				printf("\n\tgender:");
				fflush( stdin );
				gets( gender );
			    find_by_gender( s,n,gender );
				break;
			
			case 3:
				printf("\n\tname:");
				fflush( stdin );
			    gets( name );
			    find_by_name( s,n,name );
				break;	
				
			default :
			    continue;	
				
		}
	
	system("pause");
	
	}
}
void menu5(Student* s,int n)
{
	while(1){
		system("cls");
		printf("\t1.一般统计\n");
		printf("\t2.动态分析\n");
		printf("\t0.退出\n");
		printf("\t（0-2）\n");
		int option ;
		scanf("%d",&option);
		switch(option){
			case 0:
				return ;
				break;
				
		    case 1:
			    statistic( s,n );
				break;	
			
			case 2:
			    analyse( s,n );
				break;	
				
			default :
			    continue;	
		}
    system("pause");
	}
}

